Chris Moreh
Lecturer (Asst. Prof.) in Sociology
Let’s Break a Deal!
A classic probability puzzle recast
@ UCU Teach-out
11 March, 2025
## Data simulation
games = NULL
for (i in switch_choice) {
winning_door <- sample(doors, 1)
players_original_choice <- sample(doors, 1)
losing_doors <- setdiff(doors, winning_door)
door_open <- ifelse(players_original_choice == winning_door,
sample(losing_doors, 1),
setdiff(losing_doors, players_original_choice))
does_player_switch <- i
players_final_choice <- ifelse(does_player_switch,
setdiff(doors, c(door_open, players_original_choice)),
players_original_choice)
games_i <- data.frame(
switched = does_player_switch,
won = players_final_choice == winning_door
)
games <- rbind.data.frame(games_i, games)
}
## Plot the results
games |>
ggplot(aes(x = switched, fill = won)) +
geom_bar() +
scale_fill_manual(values = c("#396e0a", "#880e0e")) +
labs(x = "\nDid the player switch their choice?", fill = "Job OR Sack? ", y = "Number of games\n") +
theme_minimal() +
theme(legend.position = "top")